package com.uncp.comisiondeadmision.dao;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;

import com.uncp.comisiondeadmision.util.entity.EHistorialIgv;

public class DHistorialIgv implements IDHistorialIgv {

	private EntityManagerFactory emf;
	private EntityManager em;

	public EHistorialIgv obtenerIgv() {

		em = emf.createEntityManager();

		EHistorialIgv igv = null;

		try {

			Query query = em.createQuery("select hi from EHistorialIgv hi ORDER BY hi.int_codigv DESC");
			
			igv = (EHistorialIgv) query.setFirstResult(0).setMaxResults(1).getSingleResult();

		} catch (Exception e) {
			e.printStackTrace();
		}

		return igv;
	}

	public void setEmf(EntityManagerFactory emf) {
		this.emf = emf;
	}

}
